package com.yq.cns.utils

import androidx.recyclerview.widget.DiffUtil
import com.yq.cns.entity.NewsListEntity



class NewsListDiffCallback : DiffUtil.Callback {

    private val oldData: List<NewsListEntity>
    private val newData: List<NewsListEntity>

    constructor(oldData: List<NewsListEntity>, newData: List<NewsListEntity>) : super() {
        this.oldData = oldData
        this.newData = newData
    }


    override fun getOldListSize() = oldData.size

    override fun getNewListSize() = newData.size

    override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
        return newData[newItemPosition].equals(oldData[oldItemPosition])
    }

    override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
        return newData[newItemPosition].areContentsTheSame(oldData[oldItemPosition])
    }
}